if (import.meta.env.DEV && !sessionStorage.getItem('tokenCleared')) {
  localStorage.removeItem('TokenInfo')
  sessionStorage.setItem('tokenCleared', '1')
}
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import store from './store/index.js'  
import panelHead from './components/panelHead.vue'

//路由守卫
 router.beforeEach((to, from, next) => {
    const token = localStorage.getItem('pz-token')
    //判断非登录页面
    if(!token && to.path !== '/login'){
      next('/login')
    } /* else if (token && to.path === '/login'){
        next('/') */
    /* } */else{
        next()
    }
})
 
//createApp(App).use(router).mount('#app')  两种写法
const app = createApp(App)
for(const [key,component] of Object.entries(ElementPlusIconsVue)){
    app.component(key,component)
}
app.component('PanelHead',panelHead)
//路由挂载
app.use(router)
//store挂载
app.use(store)
app.mount('#app')